package com.myhome.money.spring.lifecycle.controller;

import com.myhome.money.spring.lifecycle.listenter.MyEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Rod
 */
@Controller
public class EventDemoController {

    @Autowired
    private ApplicationContext applicationContext;

    @RequestMapping(value = "/demo01",produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String demo01() {
        applicationContext.publishEvent(new MyEvent("这里触发一个自定义的监听器"));

        return "成功";
    }

}
